package com.verisette.framework.basic.common.config;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.corp.agi.basic.common.constant.ProjectConstant;
import org.corp.agi.basic.common.util.LogFormatter;
import org.corp.agi.basic.persistence.dao.ConfigDAO;
import org.corp.agi.basic.persistence.domain.AgiColumnRef;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;

public class ColumnRefConfigImpl {
	private static Logger logger = Logger.getLogger(ColumnRefConfigImpl.class);	
	
	
	ConfigDAO configDAO;
	
	@Autowired
	@Required
	public void setConfigDAO(ConfigDAO configDAO) {
		this.configDAO = configDAO;
	}
	
	public Map<String,AgiColumnRef> getUserStatusMap(){
		Map<String,AgiColumnRef> columRefMap = configDAO.getColumnRefMap( ProjectConstant.COL_REF_TYPE_USER_STATUS );
		
		if( columRefMap == null ){
			logger.error( LogFormatter.format("-", "-", LogFormatter.TYPE_CONFIG_ERROR, LogFormatter.OP_ENGINE, 
						  "Cannot find ColumnRef : Type = " + ProjectConstant.COL_REF_TYPE_USER_STATUS ) );
		}
		return columRefMap;
	}
	
	public List<AgiColumnRef> getUserStatusList(){
		List<AgiColumnRef> columRefList = configDAO.getColumnRefList( ProjectConstant.COL_REF_TYPE_USER_STATUS );
		
		if( columRefList == null ){
			logger.error( LogFormatter.format("-", "-", LogFormatter.TYPE_CONFIG_ERROR, LogFormatter.OP_ENGINE, 
					"Cannot find ColumnRef : Type = " + ProjectConstant.COL_REF_TYPE_USER_STATUS ) );
		}
		return columRefList;
	}
	
	public List<AgiColumnRef> getTitleList(){
		List<AgiColumnRef> columRefList = configDAO.getColumnRefList( ProjectConstant.COL_REF_TYPE_TITLE );
		
		if( columRefList == null ){
			logger.error( LogFormatter.format("-", "-", LogFormatter.TYPE_CONFIG_ERROR, LogFormatter.OP_ENGINE, 
					"Cannot find ColumnRef : Type = " + ProjectConstant.COL_REF_TYPE_TITLE ) );
		}
		return columRefList;
	}
}
